/*
 * Copyright (C), 2014-2015, 联创车盟汽车服务有限公司
 * FileName: LoginService.java
 * Author:   Freeman
 * Date:     2015年2月3日 下午11:17:12
 * Description: //模块目的、功能描述      
 * History: //修改记录
 * <author>    <time>    <version>    <desc>
 * 修改人姓名        修改时间        版本号        描述
 */
package com.linkage.service.commodity;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.linkage.pojo.consumer.User;
import com.linkage.service.consumer.UserService;

/**
 * 〈一句话功能简述〉<br> 
 * 〈功能详细描述〉
 *
 * @author Freeman
 *
 */
@Service
public class LoginService {
    @Autowired
    private UserService userService;
    
    public User login(String password,String loginName) {
         boolean bool=this.userService.login(password, loginName);
         User user=null;
         if(bool){
             user=this.userService.getOneUserByLoginName(loginName);             
         }
         return user;
    }
    public boolean logout(HttpServletRequest request){
        Object obj = request.getSession().getAttribute("LOGIN_USER_KEY_IN_SESSION");
        if (obj == null || !(obj instanceof User))
            return false;
//        request.getSession().removeAttribute("message");
        request.getSession().removeAttribute("LOGIN_USER_KEY_IN_SESSION");
        return true;
    }
}
